Visualizing Amounts in Finance

Most commonly used visualizations to compare amounts include:

1. Bar Charts
2. Diverging Bar Charts    
3. Stacked Bar Charts
4. Grouped Bar Charts (also called Clustered Bar Charts)
5. Animated Bar Charts
6. Dot Plots (also called Cleveland Dot Charts)
7. Bubble Charts
8. Heatmaps

Others include :
9.  Waterfall Charts
10. Polar Area Charts (also called Coxcomb Charts)
11. Dumbbell Charts


Most importantly, we will be using quandl api and quantmod api to import financial data in this notebook.
We can install quandl & quantmod packages and register an account on quandl.com

Create a free Quandl account and set your API key here
For more information, refer to :
https://www.quandl.com/tools/r

Importing Data (Using Quandl and quantmod API)

This notebook uses Quandl and quantmod API to import Financial Data directly to R.
Datasets used in this notebook include:

1. Historical Prices of Precious Metals 
    (Gold, Silver, Platinum and Palladium)
2. Historical Prices of Non-Ferrous Base Metals 
    (Aluminum; Copper; Lead; Nickel; Tin and Zinc)
3. Consumer Price Index for All Urban Consumers (CPI-U)
Precious Metals Prices : London Fixing (U.S. Dollars per Troy Ounce)
Base Metals Prices : Spot Prices (U.S. Dollars per metric ton)
CPI Data : CPI for U.S. City Average
Units:
Index 1982-1984=100,
Seasonally Adjusted

Frequency:
Monthly

Data Manipulation

Precious Metals Prices : London Fixing (U.S. Dollars per Troy Ounce)
Base Metals Prices : Spot Prices (U.S. Dollars per metric ton)
CPI Data : CPI for U.S. City Average
Some basic Math Calculations with CPI

Visualizing Amounts

Bar Chart
A simple way to visualize the quantitative data of a categorical variable is the bar chart. The height of
the bar is proportional to the quantity we want to visualize. They can be used for displaying data that are 
classified as nominal data/ordinal data.

They are one of the most commonly used types of plots because they are simple to create and very easy to 
interpret. They are also a flexible chart type and there are several variations of the standard bar chart.

Different types of bar charts:
- Horizontal bar charts
- Grouped or Component charts
- Stacked bar charts
- Diverging bar charts
- Animated bar charts
Diverging Bar Chart
A diverging bar chart is a bar chart with a diverging aspect; i.e. It makes comparison of amounts from a 
divergent line easy to visualize. This divergent line can represent zero, but it can also be used to simply 
separate the two distinguishing members of the dataset based on the amount.

In the plot depicted below, the divergent line is zero; Its quite easier to visualize which Categories saw a 
positive rate of inflation vs negative.
Stacked Bar Chart
The stacked bar chart extends the standard bar chart from visualizing quantity of one categorical variable 
to two. Each bar in a standard bar chart is divided into a number of sub-bars stacked end to end, each 
one corresponding to a level of the second categorical variable. The main objective of a standard bar chart 
is to compare numeric values between levels of a categorical variable. It also visualizes relative 
decomposition of each of the categories.

The stacked bar chart below depicts historical annual prices of precious metals. The two categorical 
variables: Commodity and Year. The primary categorical variable is the Commodity. It also depicts the 
relative decomposition of each of the commodities. For example, we can compare prices of 2018 vs 2019 in 
the stacked bar chart and infer that although the prices of gold, platinum and silver were steady, the 
palladium prices have risen considerably.
Grouped Bar Chart
The grouped bar chart, also known as clustered bar graph, multi-set bar chart, or grouped column chart is a 
variation of bar chart used when we need to visualize distribution of data points or making comparisons 
across different categories of data.

They are used when you want to do within-group and between-group comparisons in one single plot. For 
example, in the plot below, we can check the price comparisons of base metals within each year as well as 
over a period of time.
Animated Bar Chart
Animated bar charts are mostly used for visualization of trends over time. They provide a holistic data 
story/insight in a concise and easy to understand chart, which makes them more popular in social media.

Dot Plots

Dot plots are one of the simplest way to visualize single numerical variable with a modest number of 
observations. They are a great alternative to the bar chart and the power of these plots becomes evident 
on refining and they can easily communicate important aspects of your data to viewers. 

In the example below, we have considered depicting Gold fixing price. Although this is a simple and basic 
case of dot plot, they are capable of depicting lot more information. In the latter example, we use dot plot 
to visualize the rate of inflation from 2018 to 2019 and highlight the categories which underwent more than 
20% rise in inflation rate.
Dot Plot
Bubblechart
A bubble chart uses areas of circle to represent the quantity of a numeric variable. It is a preferred when 
we want to represent relationship between two or more numeric variables.

In the following example, we represent the prices of base metals for the year 2019.
Heatmap
A heatmap depicts values for a main variable of interest across two axis variables as a grid and uses color 
coding to represent the quantity of values.

In the below example, we generate a heatmap to depict historic monthly change in rate of inflation for major 
categories.